//reduce
val x = sc.parallelize(Array(1,2,3,4))
val z = x.reduce((a,b) => a+b)
println(z)

//saveAsTextFile
val x = sc.parallelize(Array(1,2,3,4))
x.saveAsTextFile("/tmp")
val y = sc.textFile("/tmp")
println(y.collect().mkString(","))

//collect
val x = sc.parallelize(Array(1,2,3,4))
println(x.collect().mkString(","))

//count
println(x.count())

//countByValue
println(x.countByValue())

//fold
val y = x.fold(0)((a,b) => a*b)
println(y)

//textFile
val rdd = sc.textFile("/tmp/123.txt")
rdd.partitions.size
val rdd = sc.textFile("/tmp/123.txt",2)
rdd.partitions.size

//parallelize
val array = Array(1,2,3,4,5)
val rdd = sc.parallelize(array,2)
rdd.partitions.size

//repartition
val x = sc.parallelize(Array(1,2,3,4))
val rdd = x.repartition(1)
rdd.partitions.size